//
//  ViewController.m
//  UI06_homework(qq NavigatonBar)
//
//  Created by Hanlingyu on 16/7/21.
//  Copyright © 2016年 ltq. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0.085 green:0.726 blue:1.000 alpha:1.000];
    UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:@[@"消息", @"电话"]];
    segment.frame = CGRectMake(0, 0, 120, 35);
    segment.selectedSegmentIndex = 0;
    self.navigationItem.titleView = segment;
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.backgroundColor = [UIColor whiteColor];
    [button setImage:[UIImage imageNamed:@"1.jpg"] forState:UIControlStateNormal];
    button.frame = CGRectMake(0, 2, 40, 40);
    button.layer.cornerRadius = 20;
    button.layer.masksToBounds = YES;
    [button addTarget:self action:@selector(editSelfAction:) forControlEvents:UIControlEventTouchUpInside];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addFriends:)];
    // 更改状态栏的字体颜色
    
    self.navigationController.navigationBar.hidden = NO;
    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;

       
}

- (void)editSelfAction:(UIButton *)editButton {
    NSLog(@"编辑资料");

}

- (void)addFriends:(UIBarButtonItem *)addButton {

    NSLog(@"添加好友");
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
